package org.django4j.user;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.django4j.View;
import org.django4j.XmlView;

public class UserController {
    Map<Integer, User> users = new HashMap<Integer, User>();
    
    public UserController(){
        users.put(1, new User(1, "llm", 30));
        users.put(2, new User(2, "lsj", 25));
    }
    
    public View getUser(HttpServletRequest request, HttpServletResponse response, 
            int userID){
        User user = users.get(userID);
        if (user == null){
            return new XmlView(null, HttpServletResponse.SC_NO_CONTENT);
        }
        else{
            return new XmlView(user);
        }
    }
    
    public View updateUser(HttpServletRequest request, HttpServletResponse response){
        return new XmlView();
    }
    
    public View addUser(HttpServletRequest request, HttpServletResponse response){
        return new XmlView();
    }
    
    public View deleteUser(HttpServletRequest request, HttpServletResponse response, 
            int userID){
        return new XmlView();
    }    
}
